<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8" />
<title>供应商管理 - 新增供应商</title>
<?php include $this->c['_homes']['_viewsHome'] . '/_global/_head.php';?>
</head>
<!-- BEGIN BODY -->
<body class="page-header-fixed page-sidebar-fixed">
<!-- BEGIN HEADER -->
<?php include $this->c['_homes']['_viewsHome'] . '/_global/head.php';?>
<!-- END HEADER -->
<div class="clearfix"></div>
<!-- BEGIN CONTAINER -->
<div class="page-container" >
  <!-- BEGIN HORIZONTAL MENU PAGE SIDEBAR1 -->
  <?php include $this->c['_homes']['_viewsHome'] . '/_global/menu.php';?>
  <!-- END BEGIN HORIZONTAL MENU PAGE SIDEBAR -->
  <!-- BEGIN PAGE -->
  <div class="page-content">
    <!-- BEGIN PAGE HEADER-->
    <div class="row">
      <div class="col-md-12">
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title"> 新增供应商 </h3>
        <ul class="page-breadcrumb breadcrumb">
          <li> <i class="icon-home"></i> <a href="/manage">后台</a> <i class="icon-angle-right"></i> </li>
          <li> 供应商管理 <i class="icon-angle-right"></i> </li>
          <li> <a href="/channel/supplier">供应商列表</a> <i class="icon-angle-right"></i> </li>
          <li>新增供应商</li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB-->
      </div>
    </div>
    <!-- END PAGE HEADER-->
    <!-- BEGIN PAGE CONTENT-->

    <div class="row">
      <div class="col-md-12">
        <!-- BEGIN SAMPLE FORM PORTLET-->
        <form action="/channel/saveSupplier" class="form-horizontal" onSubmit="return chkfrm();" method="post" role="form" enctype="multipart/form-data">
						<input type="hidden" name="act" value="add">
          <div class="tabbable tabbable-custom boxless">
            <div class="tab-content">
              <!--Tab0-->
              <div class="tab-pane active" id="tab_0">
                <div class="portlet box blue ">
                  <div class="portlet-title">
                    <div class="caption"> <i class="icon-reorder"></i> 基本资料 </div>
                  </div>
                  <div class="portlet-body form">
                    <div class="form-body">
                      <div class="form-group">
									<label class="control-label col-md-3">供应商名称
										<span class="required">*</span>
									</label>
									<div class="col-md-4">
										<input type="text" name="supplier" id="_supplier" value="<?=$this->data['company_name']?>" class="form-control" placeholder="供应商名称">
									</div>
								</div>
                           <div class="form-group">
                            <label for="exampleInputFile2" class="col-md-3 control-label">图片</label>
                            <div class="col-md-4">
                                <input id="exampleInputFile2" name="headimgurl" type="file">
                                <p class="help-block">只允许上传图片，2M以内</p>
                                <?php if($this->data['headimgurl']){?>
                                    <p>图片已经存在，<a href="<?=$this->data['headimgurl'];?>" target="_blank">点击查看&gt;&gt;</a></p>
                                    <?
                                }
                                ?>

                            </div>
                        </div>
                    </div>
								<div class="form-group">
									<label  class="col-md-3 control-label">供应商地址<span class="required"></span></label>
									<div class="col-md-4">
										<input type="text"  name="address" id="_address" value="<?=$this->data['address']?>" class="form-control" placeholder="例如：万家丽路888号A3栋5楼1207">
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-md-3">供应商座机
										<span class="required"></span>
									</label>
									<div class="col-md-4">
										<input type="text" class="form-control" name="tel" type="tel"  id="_tel" placeholder="比如：0731-1234567" value="<?=$this->supplier['tel']?>">
									</div>
								</div>

								<div class="form-group">
									<label class="control-label col-md-3">负责人姓名
										<span class="required"></span>
									</label>
									<div class="col-md-4">
										<input type="text"  name="suppliername" id="_suppliername" value="<?=$this->data['supplier']?>"  class="form-control" placeholder="负责人姓名">
									</div>
								</div>

								<div class="form-group">
									<label class="control-label col-md-3">负责人电话
										<span class="required"></span>
									</label>
									<div class="col-md-4">
										<input type="text" name="phone" id="_phone" onChange="checkphone()" maxlength="11" value="<?=$this->data['phone']?>"  class="form-control" placeholder="负责人联系方式">
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-md-3">负责人邮箱
									</label>
									<div class="col-md-4">
										<input type="text" name="mailbox" value="<?=$this->data['mailbox']?>"  class="form-control" placeholder="负责人邮箱">
									</div>
								</div>
								<div class="form-group" >
									<label class="control-label col-md-3">财务姓名
										<span class="required"></span>
									</label>
									<div class="col-md-4">
										<input type="text" name="finance_name" id="_finance_name" value="<?=$this->data['supplier']?>"  class="form-control" placeholder="联系方式">
									</div>
								</div>

								<div class="form-group">
									<label class="control-label col-md-3">财务电话
										<span class="required"></span>
									</label>
									<div class="col-md-4">
										<input type="text" maxlength="11" name="finance_phone" id="_finance_phone" value="<?=$this->data['phone']?>" class="form-control" placeholder="负责人联系方式">
									</div>
								</div>

								<div class="form-group" >
									<label class="control-label col-md-3">财务邮箱
										<span class="required"></span>
									</label>
									<div class="col-md-4">
										<input type="text" name="finance_email" id="_finance_email" value="<?=$this->data['mailbox']?>"  class="form-control" placeholder="联系方式">
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-md-3">付款账号
										<span class="required"></span>
									</label>
									<div class="col-md-4">
										<input type="text" name="payment_account" id="_payment_account" value="<?=$this->data['tel']?>"  class="form-control" placeholder="联系方式">
									</div>
								</div>
                      <div class="form-group">
                        <div class="col-md-9"> </div>
                      </div>
                    </div>
                    <div class="form-actions fluid">
                      <div class="col-md-offset-3 col-md-9">
                        <button class="btn green" id="tj" type="submit">提交</button>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </form>
        <!-- END SAMPLE FORM PORTLET-->
      </div>
    </div>
    <!-- END PAGE CONTENT-->
  </div>
  <!-- END PAGE -->
  <input type="hidden" id="_phone_stat" value="0">
</div>
<!-- END CONTAINER -->
<?php include $this->c['_homes']['_viewsHome'] . '/_global/_footer.php';?>
	<script>
		function ick(){
			$('#tj').click();
		}
		jQuery(document).ready(function() {
        // initiate layout and plugins
        App.init();

        // button state demo
        $('.demo-loading-btn').click(function () {
        	var btn = $(this);
        	btn.button('loading');
        	setTimeout(function () {
        		btn.button('reset');
        	}, 3000);
        });

        $("#_province").bind("change",function(){
        	_region( $(this).val(),"_city" );
        	var id = $("#_city").val()
        	if(id == ''){
        		$("#_county").html('<option value="">--县--</option>');
        	}
        });
        $("#_city").bind("change",function(){
        	_region( $(this).val(),"_county" );
        });
    });

		function checkphone(){
			var phone = $("#_phone").val();
			if(phone!=''){
				if(!(/^1[34578]\d{9}$/.test(phone)))
				{
					swal("请输入正确的手机号码");
					return false;
				}else {
					$.post("Ajaxsearchphone",{"phone":phone,"mr":Math.random()},function(msg){
						if(msg==200){
							swal("该手机号已存在");
							$("_phone_stat").css("value",1);
							return false;
						}
					});
				}
			}
		}
	</script>
	<script type="text/javascript">
		function _region(parent_id,obj){
			var _o = $("#"+obj);
			_o.empty();
			switch(obj){
				case "_city":
				_o.append('<option value="">--市/区--</option>');
				break;
				case "_county":
				_o.append('<option value="">--县--</option>');
				break;
			}
			if(parent_id!=""){
				$.post("/channel/supplierAjax",{"act":"getregion","parent_id":parent_id},function(msg){
					if(msg!=""){

						var json = eval("("+msg+")");
						if(json.code == 200){

							$.each(json.data,function(i,v){
								_o.append('<option value="'+v.region_id+'">'+v.region_name+'</option>');
							});

						}

					}
				});
			}
		}

		function chkfrm(){
			if($("#_supplier").prop("value")==""){
				swal("请填写公司名称");
				$("#_supplier").focus();
				return false;
			}

			if($("#_phone_stat").prop("value")==1){
				return false;
			}

			if($("#_suppliername").val()==""){
				swal("请填写负责人");
				$("#_suppliername").focus();
				return false;
			}
			if($("#_phone").prop("value")==""){
				swal("请填写负责人电话");
				$("#_phone").focus();
				return false;
			}

		}
	</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>